import request from "../utils/http";

// 获取仓库列表 GET /house
export function getHouseList(params) {
  return request({
    url: "/house",
    method: "get",
    params: params,
  });
}

// 获取单个仓库详情 GET /house/:id
export function getHouseDetail(id) {
  return request({
    url: `/house/${id}`,
    method: "get",
  });
}

// 新增仓库 POST /house
export function addHouse(data) {
  return request({
    url: "/house",
    method: "post",
    data: data,
  });
}

// 更新仓库信息 PUT /house/:id
export function updateHouse(id, data) {
  return request({
    url: `/house/${id}`,
    method: "put",
    data: data,
  });
}

// 停用 (软删除) 仓库 DELETE /house/:id
export function deleteHouse(id) {
  return request({
    url: `/house/${id}`,
    method: "delete",
  });
}

export function getUsersList(params) {
  return request({
    url: "/users",
    method: "get",
    params: params,
  });
}

// 仓库区域

// 获取某个仓库下的区域列表 GET /house/:houseId/areas
export function getHouseAreas(houseId, params) {
  return request({
    url: `/house/${houseId}/areas`,
    method: "get",
    params: params,
  });
}

// 获取单个区域详情 GET /house/areas/:id
export function getAreaDetail(id) {
  return request({
    url: `/house/areas/${id}`,
    method: "get",
  });
}

// 新增仓库区域 POST /house/:houseId/areas
export function addHouseArea(houseId, data) {
  return request({
    url: `/house/${houseId}/areas`,
    method: "post",
    data: data,
  });
}

// 更新仓库区域信息 PUT /house/areas/:id
export function updateHouseArea(id, data) {
  return request({
    url: `/house/areas/${id}`,
    method: "put",
    data: data,
  });
}

// 停用 (软删除) 仓库区域 DELETE /house/areas/:id
export function deleteHouseArea(id) {
  return request({
    url: `/house/areas/${id}`,
    method: "delete",
  });
}
